# -*- coding=gbk -*-
import sys
import smtplib
from email.header import Header
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import os
import urllib
import xml.dom.minidom

FROMADDR = "mape2emonitoring_SVC_BE@nokia.com"
#if level == 'ResultNotFound':
#	TOADDRS  = ['ext-duan.ken@nokia.com']
#else:
#	TOADDRS  = ['ext-duan.ken@nokia.com']
TOADDRS  = ['ext-duan.ken@nokia.com']
	
SUBJECT  = "China_Product_SW_Update_Schedule_SD Modify Notification" 

msg = MIMEMultipart('alternatvie')
msg['Subject'] = Header("China_Product_SW_Update_Schedule_SD Modify Notification","utf-8") 
msg['From'] = r"%s <mape2emonitoring_SVC_BE@nokia.com>" % Header("Mail","utf-8") 
msg['To'] = 'ext-duan.ken@nokia.com; devilkin64@126.com'


html = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <meta http-equiv="Content-Type"
 content="text/html; charset=utf-8">
  <title>Email Template - Metalab
Steph</title>
<!--[if gte mso 9]>
<style type="text/css">
.body {background: #234865 url('images/body-bg.jpg');} .case {background: none;}
</style>
<![endif]-->
</head>
<body class="div"
 style="margin: 0pt; padding: 0pt; background-color: rgb(35, 72, 101); background-image: url(images/div-bg.jpg); background-repeat: repeat;"
 topmargin="0" leftmargin="0" marginheight="0"
 marginwidth="0">
<!--100% body table-->
<table border="0" cellpadding="0"
 cellspacing="0" width="100%">
  <tbody>
    <tr>
      <td class="case"
 style="background-color: rgb(35, 72, 101); background-image: url(images/body-bg.jpg); background-repeat: repeat;"
 bgcolor="#234865"><!--[if gte mso 9]>
<td style="background: none;">
<![endif]--><!--header text-->
      <table
 style="background-image: url(images/header-lines.jpg); background-position: center bottom; background-repeat: repeat-x;"
 align="center" bgcolor="#1d3952" border="0"
 cellpadding="0" cellspacing="0" width="100%">
        <tbody>
          <tr>
            <td>
            <table id="top"
 align="center" border="0" cellpadding="0"
 cellspacing="0" width="578">
              <tbody>
                <tr>
                  <td align="center"
 height="60" valign="top">
                  <table
 style="width: 574px; height: 1px;" border="0"
 cellpadding="0" cellspacing="0">
                    <tbody>
                      <tr>
                        <td height="10"></td>
                      </tr>
                    </tbody>
                  </table>
                  <br>
                  </td>
                </tr>
              </tbody>
            </table>
            </td>
          </tr>
        </tbody>
      </table>
<!--/header text--><!--intro-->
      <table align="center" border="0"
 cellpadding="0" cellspacing="0" width="578">
        <tbody>
          <tr>
            <td height="20"
 valign="top"></td>
          </tr>
          <tr>
            <td
 background="images/header-bg.jpg" bgcolor="#c6d2db"
 height="79" valign="top">
            <table border="0"
 cellpadding="0" cellspacing="0" width="100%">
              <tbody>
                <tr>
                  <td height="22"
 width="68%"></td>
                </tr>
                <tr>
                  <td valign="top">
                  <table
 style="height: 37px; width: 575px;" border="0"
 cellpadding="0" cellspacing="0">
                    <tbody>
                      <tr>
                        <td valign="middle"
 width="93%">
                        <h1
 style="margin: 0px; padding: 0px; font-family: Helvetica,Arial,sans-serif; font-size: 24px; text-shadow: rgb(255, 255, 255) 1px 1px 1px; color: rgb(36, 74, 103);">&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NOC Build
&amp; Automation Test Result&nbsp;<span
 style="font-weight: normal;"></span></h1>
                        </td>
                      </tr>
                    </tbody>
                  </table>
                  </td>
                </tr>
              </tbody>
            </table>
            </td>
          </tr>
          <tr>
            <td height="20"
 valign="top"></td>
          </tr>
        </tbody>
      </table>
<!--/intro--><!--content section-->
      <table align="center" border="0"
 cellpadding="20" cellspacing="0" width="576">
        <tbody>
          <tr>
            <td
 style="border: 1px solid rgb(25, 48, 68); -moz-border-radius-topleft: 8px; -moz-border-radius-topright: 8px; -moz-border-radius-bottomright: 8px; -moz-border-radius-bottomleft: 8px;"
 background="images/content-bg.jpg" bgcolor="#1c3851"
 valign="top">
            <h2
 style="margin: 0px; padding: 0px; font-family: Helvetica,Arial,sans-serif; font-size: 18px; text-shadow: rgb(51, 51, 51) 1px 1px 1px; color: rgb(98, 182, 238);">SVN
Infomaiton</h2>
<!--break-->
            <table
 style="font-family: Arial; color: rgb(255, 255, 255);"
 border="0" cellpadding="0" cellspacing="0"
 width="100%">
              <tbody>
                <tr>
                  <td height="10"><small><span
 style="font-weight: bold;">Last
Modify: var_modify </span></small><br>
                  <small><span
 style="font-weight: bold;">Current Version:
var_version</span><br
 style="font-weight: bold;">
                  <span
 style="font-weight: bold;">Commit Time:
var_commit_time</span>
                  <br
 style="font-weight: bold;">
                  <span
 style="font-weight: bold;">Commit Date:
ver_commit_date</span></small></td>
                </tr>
              </tbody>
            </table>
            <table border="0"
 cellpadding="0" cellspacing="0" width="100%">
              <tbody>
                <tr>
                  <td height="40"
 valign="middle"> <img
 src="images/line.jpg" height="11" width="533"></td>
                </tr>
              </tbody>
            </table>
            <h2
 style="margin: 0px; padding: 0px; font-family: Helvetica,Arial,sans-serif; font-size: 18px; text-shadow: rgb(51, 51, 51) 1px 1px 1px; color: rgb(98, 182, 238);">Build
&amp; Unit Test Result</h2>
            <table border="0"
 cellpadding="0" cellspacing="0" width="100%">
              <tbody>
                <tr>
                  <td valign="top"
 width="53%">
                  <h2
 style="margin: 0px; padding: 0px; font-family: Helvetica,Arial,sans-serif; font-size: 18px; text-shadow: rgb(51, 51, 51) 1px 1px 1px; color: rgb(255, 255, 255);"><small><small><big><span
 style="font-weight: bold; color: rgb(255, 204, 102);">Build
Result</span></big><br>
                  </small> <small><span
 style="font-weight: bold;"></span></small></small></h2>
                  <h2
 style="margin: 0px; padding: 0px; font-family: Helvetica,Arial,sans-serif; font-size: 18px; text-shadow: rgb(51, 51, 51) 1px 1px 1px; color: rgb(255, 255, 255);"><span
 style="color: rgb(51, 204, 0);">Var_build_result</span><br>
                  </h2>
                  <h2
 style="margin: 0px; padding: 0px; font-family: Helvetica,Arial,sans-serif; font-size: 18px; text-shadow: rgb(51, 51, 51) 1px 1px 1px; color: rgb(255, 204, 102);"><small><span
 style="font-weight: bold;">Unit Test result</span></small></h2>
                  <small
 style="color: rgb(255, 255, 255);"><span
 style="font-family: Arial; font-weight: bold;">Pass
Cases Number: var_pass_case_number_u</span><br
 style="font-family: Arial; font-weight: bold;">
                  <span
 style="font-family: Arial; font-weight: bold;">Fail
Cases Number: var_fail_case_number_u</span><br
 style="font-family: Arial; font-weight: bold;">
                  <span
 style="font-family: Arial; font-weight: bold;">Skip
Cases Number: var_skip_case_number_u</span></small><br>
                  </td>
                </tr>
              </tbody>
            </table>
<!--line-->
            <table border="0"
 cellpadding="0" cellspacing="0" width="100%">
              <tbody>
                <tr>
                  <td height="40"
 valign="middle"> <img
 src="images/line.jpg" height="11" width="533"></td>
                </tr>
              </tbody>
            </table>
<!--/line-->
            <h2
 style="margin: 0px; padding: 0px; font-family: Helvetica,Arial,sans-serif; font-size: 18px; text-shadow: rgb(51, 51, 51) 1px 1px 1px; color: rgb(98, 182, 238);">Automation
Test Result &nbsp;</h2>
<!--break-->
            <table border="0"
 cellpadding="0" cellspacing="0" width="100%">
              <tbody>
                <tr>
                  <td height="10"><span
 style="font-family: Arial; font-weight: bold; color: rgb(255, 204, 102);">Smoke
Test result:</span><br
 style="color: rgb(255, 255, 255);">
                  <small
 style="color: rgb(255, 255, 255);"><span
 style="font-family: Arial; font-weight: bold;">Pass
Cases Number: var_pass_case_number_s</span><br
 style="font-family: Arial; font-weight: bold;">
                  <span
 style="font-family: Arial; font-weight: bold;">Fail
Cases Number: var_fail_case_number_s</span><br
 style="font-family: Arial; font-weight: bold;">
                  <span
 style="font-family: Arial; font-weight: bold;">Error
Cases Number: var_error_case_number_s</span></small><br>
                  </td>
                </tr>
              </tbody>
            </table>
            <table border="0"
 cellpadding="0" cellspacing="0" width="100%">
              <tbody>
                <tr>
                  <td height="10"><span
 style="font-family: Arial; color: rgb(255, 204, 102); font-weight: bold;">Full
Test result:</span><br>
                  <small
 style="color: rgb(255, 255, 255);"><span
 style="font-family: Arial; font-weight: bold;">Pass
Cases Number: var_pass_case_number_f</span><br
 style="font-family: Arial; font-weight: bold;">
                  <span
 style="font-family: Arial; font-weight: bold;">Fail
Cases Number: var_fail_case_number_f</span><br
 style="font-family: Arial; font-weight: bold;">
                  <span
 style="font-family: Arial;"><span
 style="font-weight: bold;">Error</span></span><span
 style="font-family: Arial; font-weight: bold;"> Cases
Number: var_error_case_number_f</span></small></td>
                </tr>
              </tbody>
            </table>
<!--/break--></td>
          </tr>
        </tbody>
      </table>
<!--/content section--><!--content section-->
      <table align="center" border="0"
 cellpadding="0" cellspacing="0" width="578">
        <tbody>
          <tr>
            <td>
            <table border="0"
 cellpadding="20" cellspacing="0" width="578">
              <tbody>
                <tr>
                  <td align="center">
                  <table border="0"
 cellpadding="0" cellspacing="0" width="200">
                    <tbody>
                      <tr>
                        <td><br>
                        </td>
                        <td> <forwardtoafriend
 style="margin: 0px; padding: 0px; font-family: Helvetica,Arial,sans-serif; font-weight: bold; font-size: 16px; text-shadow: rgb(0, 0, 0) 1px 1px 1px; color: rgb(98, 182, 238);">Test
reuslt on FTP Link</forwardtoafriend></td>
                      </tr>
                    </tbody>
                  </table>
                  </td>
                  <td align="center">
                  <table border="0"
 cellpadding="0" cellspacing="0" width="200">
                    <tbody>
                      <tr>
                        <td><br>
                        </td>
                        <td> <unsubscribe
 style="margin: 0px; padding: 0px; font-family: Helvetica,Arial,sans-serif; font-size: 16px; font-weight: bold; text-shadow: rgb(0, 0, 0) 1px 1px 1px; color: rgb(98, 182, 238);">CC
Dash Board Link</unsubscribe>
                        </td>
                      </tr>
                    </tbody>
                  </table>
                  </td>
                </tr>
              </tbody>
            </table>
            </td>
          </tr>
        </tbody>
      </table>
<!--/content section--><!--footer-->
      <table
 style="background-image: url(images/footer-lines.jpg); background-position: center top; background-repeat: repeat-x;"
 align="center" bgcolor="#1c293b" border="0"
 cellpadding="0" cellspacing="0" width="100%">
        <tbody>
          <tr>
            <td>
            <table align="center"
 border="0" cellpadding="0" cellspacing="0"
 width="578">
              <tbody>
                <tr>
                  <td align="center"
 height="60" valign="top"><br>
                  <p
 style="margin: 0px; padding: 0px; font-family: Helvetica,Arial,sans-serif; font-size: 13px; color: rgb(48, 100, 141); text-shadow: rgb(0, 0, 0) 1px 1px 1px; font-weight: bold;">Design
by Ken Duan</p>
                  <p
 style="margin: 0px; padding: 0px; font-family: Helvetica,Arial,sans-serif; font-size: 13px; color: rgb(48, 100, 141); text-shadow: rgb(0, 0, 0) 1px 1px 1px; font-weight: bold;">Service</p>
                  <p
 style="margin: 0px; padding: 0px; font-family: Helvetica,Arial,sans-serif; font-size: 13px; color: rgb(48, 100, 141); text-shadow: rgb(0, 0, 0) 1px 1px 1px; font-weight: bold;">Neusoft
corporation</p>
                  </td>
                </tr>
              </tbody>
            </table>
            </td>
          </tr>
        </tbody>
      </table>
<!--/footer--> </td>
    </tr>
  </tbody>
</table>
<!--/100% body table-->
</body>
</html>
""" 
html_part = MIMEText(html,'html')
html_part.set_charset('utf-8') 
msg.attach(html_part) 


server = smtplib.SMTP('smtp.nokia.com', 25)
server.set_debuglevel(1)
server.ehlo()
##server.starttls()
##server.login(LOGIN, PASSWORD)
server.sendmail(FROMADDR, TOADDRS, msg.as_string())
server.quit()
